LOYOLA COLLEGE (AUTONOMOUS), CHENNAI – 600 034
B.Sc. DEGREE EXAMINATION – STATISTICS
|
FIFTH SEMESTER – APRIL 2007
ST 5401 – C AND C ++
Date & Time: 04/05/2007 / 1:00 – 4:00 Dept. No. Max. : 100 Marks
PART A
Answer all the questions. 10 X 2 = 20
- Explain briefly “ scanf” and “printf” with an illustration.
- Write a program to output the following multiplication table.
5 X 1 = 5
5 X 2 = 10
……….
……….
5 X 10 = 50
- Explain decrement operator with an example.
- Write a program to convert the Fahrenheit to Celsius the following conversion formula: C = (F-32)/ 1.8.
- Identify syntax errors in the following program. After correcting, what output would you expect when you execute it?
Main ()
{
int r,c;
float perimeter: area,
c=3.1415;
r=5;
perimeter = 2.0 c*r;
area= c*r*r;
printf(“%f”,”%d”,&perimeter, &area)
}
- Mention any one salient feature of C++ when compared to C.
- What is the output of the following program?
main ()
{
int a = 2, n=100;
while(a<n)
{
cout<<a<<endl;
a=a*a;
}
}
- Write a program to find the largest number of the two numbers in C++.
- What is function in C++? And give an example for function.
- What is the output, corresponding to the following segment?
a=10;
b=15;
x=(a>b)?a:b;
cout<<x;
PART B
Answer any five questions. 5 X 8 = 40
- Explain different types of constants in c programming.
- The traveling time by train from one city to another city is given in terms of minutes (eg. 280 minutes). Write a c program that reads the given value, converts it into hours: minutes format and display the same.
- When the principal, rate of interest and period of deposit are given, write a c program to compute the simple interest and compound interest using function.
- There are three categories (A, B, C) of employees in a company. They are charged 30%, 20% and 15% respectively of their salaries as income tax. Write a c program to find the income tax to be paid by him.
- The commission on a representative’s sales is calculated as follows:
a). if sales<Rs. 500, then there is no commission.
b). if Rs. 500 < sales < Rs. 5000, then commission = 10% of sales.
c). if sales > Rs. 5000, then commission = 5000 + 8% of sales .
Write a C++ program which reads in total sales and calculates commission.
- Write a C++ program to calculate perimeter with help of function overloading using the following conditions.
a). when two sides are equal then perimeter = 2(a+(a2 – h2)) units.
b). when three sides are known but not equal perimeter = a + b +c
- Write a C++ program to calculate addition of two matrices with the order of 4X4.
- Develop a function in C++ and calculate the factorial value of an integer n. Using this in the main () function to compute ncr.
PART C
Answer any two questions. 2 X 20 = 40
- a). Explain switch statement in C and give an example with the same.(5+5)
b). Write a C program to calculate mean and variance for N values with help of
array. (10)
- a). Explain nested if statement with suitable example. (5+5)
- b). Explain one and two-dimensional arrays with examples. (5+5)
- a). Explain function overloading. (5)
b). Write a C++ program with help of function overloading to find out the largest number among two and three numbers. (15)
Latest Govt Job & Exam Updates: